﻿using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;

namespace XYS.Core.Api.Middlewares
{
    /// <summary>
    /// 
    /// </summary>
    public interface IHttpStreamHandle
    {
        /// <summary>
        /// 优先级，数字越大 越早处理
        /// 小于0 则不处理
        /// </summary>
        int PriorityLevel { get; }

        /// <summary>
        /// 开始执行
        /// </summary>
        /// <param name="scope"></param>
        /// <param name="httpContext"></param>
        /// <param name="resqustBody"></param>
        /// <param name="newResqustBody"></param>
        /// <returns></returns>
        object Invoke(IServiceScope scope, HttpContext httpContext, string resqustBody, out string newResqustBody);

        /// <summary>
        /// Nexted
        /// </summary>
        /// <param name="scope"></param>
        /// <param name="httpContext"></param>
        /// <param name="responseBody"></param>
        /// <param name="invokeResult"></param>
        /// <returns></returns>
        string Nexted(IServiceScope scope, HttpContext httpContext, string responseBody, object invokeResult);

        /// <summary>
        /// 流程结束
        /// </summary>
        /// <param name="scope"></param>
        /// <param name="httpContext"></param>
        /// <param name="nextedResult"></param>
        void ProEnd(IServiceScope scope, HttpContext httpContext, object nextedResult);
    }
}